﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Fis.Win.Utils
{
    public class ReportFactory
    {
        public static void CreateReport(System.IO.Stream layout, object dataSource)
        {
            var xr = new DevExpress.XtraReports.UI.XtraReport();
            xr.LoadLayout(layout);
            xr.DataSource = dataSource;
            xr.ShowPreviewDialog();
        }

        public static void CreateReport(string repx, object dataSource)
        {
            var uri = string.Format("{0}\\{1}", Agile.Engine.ObjectContext.Environment.Config, repx);
            var stream = Agile.Engine.Utils.IOUtils.InputStream(uri);
            CreateReport(stream, dataSource);
        }
    }
}
